home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cmdline.lha / cmdline / src / cmd / quoted.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-03  |  1.6 KB  |  59 lines

  1. //------------------------------------------------------------------------
  2. // ^FILE: quoted.h - a class for "quoted" strings
  3. //
  4. // ^DESCRIPTION:
  5. //    This file implements a quoted-string class.  The main purpose of
  6. //    this class is the input extraction operator (operator>>) which
  7. //    reads a quoted string from input (enclosed in either single or
  8. //    double quotes) and places the result (minus containing quotes)
  9. //    into a character string.  Single and double quotes may be made part
  10. //    of the string be preceding them with a backslash ('\') in the input
  11. //    stream.
  12. //
  13. // ^HISTORY:
  14. //    05/01/92    Brad Appleton    <brad@ssd.csd.harris.com>    Created
  15. //-^^---------------------------------------------------------------------
  16.  
  17. #ifndef _quoted_h
  18. #define _quoted_h
  19.  
  20. class  istream ;
  21. class  QuotedString {
  22. public:
  23.       // constructors and destructors
  24.    QuotedString(unsigned  max_size);
  25.  
  26.    QuotedString(const char * str);
  27.  
  28.    QuotedString(const char * str, unsigned  max_size);
  29.  
  30.    QuotedString(const QuotedString & qstr);
  31.  
  32.    virtual ~QuotedString(void);
  33.  
  34.       // assignment
  35.    QuotedString &
  36.    operator=(const QuotedString & qstr);
  37.  
  38.    QuotedString &
  39.    operator=(const char * str);
  40.  
  41.       // convert to a string
  42.    operator  char*(void) { return  buffer; }
  43.  
  44.       // operator >> reads a quoted string from input.
  45.       // If no beginning or ending quote is seen, than
  46.       // a message is printed on cerr and the failbit
  47.       // of the input stream is set.
  48.       //
  49.    friend  istream &
  50.    operator>>(istream & is, QuotedString & qstr);
  51.  
  52. private:
  53.    unsigned  size;
  54.    char    * buffer;
  55. } ;
  56.  
  57. #endif  /* _quoted_h */
  58.  
  59.